package org.fuys.coder.domain.substance.model.vo;

import lombok.Data;
import org.fuys.coder.domain.config.service.impl.CoderRecommendConfig;
import org.fuys.coder.domain.category.model.vo.CategoryVO;
import org.fuys.coder.domain.user.model.vo.repo.AuthorVO;
import org.jetbrains.annotations.NotNull;

import java.util.Date;

/**
 * @projectName: fuys-low-coder
 * @package: org.fuys.coder.domain.substance.model.vo
 * @className: SubstanceVO
 * @author: WangJing
 * @description: 内容视图类 使得不和基础层的PO进行交互
 * @date: 2024/6/25 16:28
 * @version: 1.0
 */
@Data
public class SubstanceVO implements Comparable<SubstanceVO>{
    private Long id;
    private String title;
    private String description;
    private Long coverId;
    private Integer thumbCount;
    private Integer favoriteCount;
    private Integer hateCount;
    private Integer viewCount;
    private Date createTime;
    private String categoryName;
    private Integer categoryId;
    private AuthorVO authorVO;
    private Double hot;
    private String coverUrl;
    private CategoryVO categoryVO;

    @Override
    public int compareTo(@NotNull SubstanceVO o) {
        return this.hot.compareTo(o.hot);
    }

    public Double calculateHot(CoderRecommendConfig config){
        double res=0.0;
        res+=config.getHotThumbWeight()*this.getThumbCount().doubleValue();
        res+=config.getHotFavWeight()*this.getFavoriteCount().doubleValue();
        return res;
    }
}
